package gk.cxd.friday.repository;

import gk.cxd.friday.model.SysUser;
import gk.cxd.friday.repository.custom.SysUserCustomRepository;
import org.springframework.data.domain.Example;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface SysUserRepository extends JpaRepository<SysUser,Long>, SysUserCustomRepository {
    /**
     * 根据id删除用户
     * @param userIds
     * @return
     */
    @Modifying
    @Query(value = " update sys_user set del_flag = '2' where user_id in :userIds",nativeQuery = true)
    int deleteUserByIds(@Param("userIds") Long[] userIds);

    /**
     *根据id删除用户(物理删除)
     */
    @Modifying
    @Query(value = " delete from sys_user_role where user_id=:userId",nativeQuery = true)
    int deleteUserRoleByUserId(@Param("userId")Long userId);
}
